
<h1><span class="yiyi-st" id="yiyi-12">numpy.argmin</span></h1>
        <blockquote>
        <p>原文：<a href="https://docs.scipy.org/doc/numpy/reference/generated/numpy.argmin.html">https://docs.scipy.org/doc/numpy/reference/generated/numpy.argmin.html</a></p>
        <p>译者：<a href="https://github.com/wizardforcel">飞龙</a> <a href="http://usyiyi.cn/">UsyiyiCN</a></p>
        <p>校对：（虚位以待）</p>
        </blockquote>
    
<dl class="function">
<dt id="numpy.argmin"><span class="yiyi-st" id="yiyi-13"> <code class="descclassname">numpy.</code><code class="descname">argmin</code><span class="sig-paren">(</span><em>a</em>, <em>axis=None</em>, <em>out=None</em><span class="sig-paren">)</span><a class="reference external" href="http://github.com/numpy/numpy/blob/v1.11.3/numpy/core/fromnumeric.py#L976-L1033"><span class="viewcode-link">[source]</span></a></span></dt>
<dd><p><span class="yiyi-st" id="yiyi-14">返回沿轴的最小值的索引。</span></p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name">
<col class="field-body">
<tbody valign="top">
<tr class="field-odd field"><th class="field-name"><span class="yiyi-st" id="yiyi-15">参数：</span></th><td class="field-body"><p class="first"><span class="yiyi-st" id="yiyi-16"><strong>a</strong>：array_like</span></p>
<blockquote>
<div><p><span class="yiyi-st" id="yiyi-17">输入数组。</span></p>
</div></blockquote>
<p><span class="yiyi-st" id="yiyi-18"><strong>axis</strong>：int，可选</span></p>
<blockquote>
<div><p><span class="yiyi-st" id="yiyi-19">默认情况下，索引位于展平的数组中，否则沿着指定的轴。</span></p>
</div></blockquote>
<p><span class="yiyi-st" id="yiyi-20"><strong>out</strong>：数组，可选</span></p>
<blockquote>
<div><p><span class="yiyi-st" id="yiyi-21">如果提供，结果将被插入到此数组中。</span><span class="yiyi-st" id="yiyi-22">它应该是合适的形状和类型。</span></p>
</div></blockquote>
</td>
</tr>
<tr class="field-even field"><th class="field-name"><span class="yiyi-st" id="yiyi-23">返回：</span></th><td class="field-body"><p class="first"><span class="yiyi-st" id="yiyi-24"><strong>index_array</strong>：intar的ndarray</span></p>
<blockquote class="last">
<div><p><span class="yiyi-st" id="yiyi-25">数组中的数组。</span><span class="yiyi-st" id="yiyi-26">它与<em class="xref py py-obj">a.shape</em>具有相同的形状，且沿着<em class="xref py py-obj">轴</em>的尺寸已删除。</span></p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title"><span class="yiyi-st" id="yiyi-27">也可以看看</span></p>
<p><span class="yiyi-st" id="yiyi-28"><a class="reference internal" href="numpy.ndarray.argmin.html#numpy.ndarray.argmin" title="numpy.ndarray.argmin"><code class="xref py py-obj docutils literal"><span class="pre">ndarray.argmin</span></code></a>，<a class="reference internal" href="numpy.argmax.html#numpy.argmax" title="numpy.argmax"><code class="xref py py-obj docutils literal"><span class="pre">argmax</span></code></a></span></p>
<dl class="last docutils">
<dt><span class="yiyi-st" id="yiyi-29"><a class="reference internal" href="numpy.amin.html#numpy.amin" title="numpy.amin"><code class="xref py py-obj docutils literal"><span class="pre">amin</span></code></a></span></dt>
<dd><span class="yiyi-st" id="yiyi-30">沿给定轴的最小值。</span></dd>
<dt><span class="yiyi-st" id="yiyi-31"><a class="reference internal" href="numpy.unravel_index.html#numpy.unravel_index" title="numpy.unravel_index"><code class="xref py py-obj docutils literal"><span class="pre">unravel_index</span></code></a></span></dt>
<dd><span class="yiyi-st" id="yiyi-32">将平坦索引转换为索引元组。</span></dd>
</dl>
</div>
<p class="rubric"><span class="yiyi-st" id="yiyi-33">笔记</span></p>
<p><span class="yiyi-st" id="yiyi-34">在多次出现最小值的情况下，返回与第一次出现相对应的索引。</span></p>
<p class="rubric"><span class="yiyi-st" id="yiyi-35">例子</span></p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">6</span><span class="p">)</span><span class="o">.</span><span class="n">reshape</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span>
<span class="go">array([[0, 1, 2],</span>
<span class="go">       [3, 4, 5]])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">np</span><span class="o">.</span><span class="n">argmin</span><span class="p">(</span><span class="n">a</span><span class="p">)</span>
<span class="go">0</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">np</span><span class="o">.</span><span class="n">argmin</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">axis</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span>
<span class="go">array([0, 0, 0])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">np</span><span class="o">.</span><span class="n">argmin</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">axis</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
<span class="go">array([0, 0])</span>
</pre></div>
</div>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">b</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">6</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">b</span><span class="p">[</span><span class="mi">4</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">b</span>
<span class="go">array([0, 1, 2, 3, 0, 5])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">np</span><span class="o">.</span><span class="n">argmin</span><span class="p">(</span><span class="n">b</span><span class="p">)</span> <span class="c1"># Only the first occurrence is returned.</span>
<span class="go">0</span>
</pre></div>
</div>
</dd></dl>
